package com.hqyj.controller;

import com.hqyj.pojo.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/test")
public class IndexController {
    @RequestMapping("/index")//配置方法的映射地址
//    @ResponseBody//返回响应数据
    public String index(){
        //返回页面前缀
        return "index";
    }
    //演示请求处理流程
    @RequestMapping("testIndex")
    public ModelAndView testIndex(){
        //请求service返回数据模型
        String info = "你好";
        //创建modelAndView对象
        ModelAndView mv = new ModelAndView();
        //添加数据模型
        mv.addObject("info",info);
        //添加视图
        mv.setViewName("index");
        return mv;
    }
    @RequestMapping( "/login1")
    public String login(UserInfo userInfo){
        System.out.println(userInfo);
        return "index";
    }
    @RequestMapping( "/loginParam")
    public String loginParam(@RequestParam("userName") String name,@RequestParam("userPwd") String pwd){

        System.out.println("name="+name);
        System.out.println("pwd="+pwd);
        return "index";
    }
}
